home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / Think-Pascal-7.0.cpt / THINK Pascal Interfaces / MIDI.p < prev    next >
Encoding:
Text File  |  1991-04-03  |  9.6 KB  |  268 lines  |  [TEXT/PJMM]

  1. {    This file has been processed by The THINK Pascal Source Converter, v1.1.    }
  2.  
  3. {
  4. Created: Tuesday, January 8, 1991 at 10:53 AM
  5.     MIDI.p
  6.     Pascal Interface to the Macintosh Libraries
  7.  
  8.             Copyright © 1988-1990, Apple Computer, Inc.
  9.             All Rights Reserved
  10. }
  11.  
  12.  
  13. {$IFC UNDEFINED UsingIncludes}
  14. {$SETC UsingIncludes := 0}
  15. {$ENDC}
  16.  
  17.  
  18.     UNIT MIDI;
  19.     INTERFACE USES    Types;
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. CONST
  34. midiToolNum = 4;                {tool number of MIDI Manager for SndDispVersion call}
  35. midiMaxNameLen = 31;            {maximum number of characters in port and client names}
  36.  
  37. { Time formats }
  38. midiFormatMSec = 0;             {milliseconds}
  39. midiFormatBeats = 1;            {beats}
  40. midiFormat24fpsBit = 2;         {24 frames/sec.}
  41. midiFormat25fpsBit = 3;         {25 frames/sec.}
  42. midiFormat30fpsDBit = 4;        {30 frames/sec. drop-frame}
  43. midiFormat30fpsBit = 5;         {30 frames/sec.}
  44. midiFormat24fpsQF = 6;          {24 frames/sec. longInt format }
  45. midiFormat25fpsQF = 7;          {25 frames/sec. longInt format }
  46. midiFormat30fpsDQF = 8;         {30 frames/sec. drop-frame longInt format }
  47. midiFormat30fpsQF = 9;          {30 frames/sec. longInt format }
  48. midiInternalSync = 0;           {internal sync}
  49. midiExternalSync = 1;           {external sync}
  50.  
  51. { Port types}
  52. midiPortTypeTime = 0;           {time port}
  53. midiPortTypeInput = 1;          {input port}
  54. midiPortTypeOutput = 2;         {output port}
  55. midiPortTypeTimeInv = 3;        {invisible time port}
  56.  
  57. { OffsetTimes  }
  58. midiGetEverything = $7FFFFFFF;  {get all packets, regardless of time stamps}
  59. midiGetNothing = $80000000;     {get no packets, regardless of time stamps}
  60. midiGetCurrent = $00000000;     {get current packets only}
  61.  
  62. {    MIDI data and messages are passed in MIDIPacket records (see below).
  63.     The first byte of every MIDIPacket contains a set of flags
  64.    
  65.     bits 0-1    00 = new MIDIPacket, not continued
  66.                      01 = begining of continued MIDIPacket
  67.                      10 = end of continued MIDIPacket
  68.                     11 = continuation
  69.     bits 2-3     reserved
  70.   
  71.     bits 4-6      000 = packet contains MIDI data
  72.    
  73.                      001 = packet contains MIDI Manager message
  74.    
  75.     bit 7              0 = MIDIPacket has valid stamp
  76.                         1 = stamp with current clock}
  77. midiContMask = $03;
  78. midiNoCont = $00;
  79. midiStartCont = $01;
  80. midiMidCont = $03;
  81. midiEndCont = $02;
  82. midiTypeMask = $70;
  83. midiMsgType = $00;
  84. midiMgrType = $10;
  85. midiTimeStampMask = $80;
  86. midiTimeStampCurrent = $80;
  87. midiTimeStampValid = $00;
  88.  
  89. {    MIDI Manager MIDIPacket command words (the first word in the data field
  90.     for midiMgrType messages)}
  91. midiOverflowErr = $0001;
  92. midiSCCErr = $0002;
  93. midiPacketErr = $0003;
  94. midiMaxErr = $00FF;             {all command words less than this value  are error indicators}
  95.  
  96. { Valid results to be returned by readHooks }
  97. midiKeepPacket = 0;
  98. midiMorePacket = 1;
  99. midiNoMorePacket = 2;
  100.  
  101. { Errors: }
  102. midiNoClientErr = -250;         {no client with that ID found}
  103. midiNoPortErr = -251;           {no port with that ID found}
  104. midiTooManyPortsErr = -252;     {too many ports already installed in the system}
  105. midiTooManyConsErr = -253;      {too many connections made}
  106. midiVConnectErr = -254;         {pending virtual connection created}
  107. midiVConnectMade = -255;        {pending virtual connection resolved}
  108. midiVConnectRmvd = -256;        {pending virtual connection removed}
  109. midiNoConErr = -257;            {no connection exists between specified ports}
  110. midiWriteErr = -258;            {MIDIWritePacket couldn't write to all connected ports}
  111. midiNameLenErr = -259;          {name supplied is longer than 31 characters}
  112. midiDupIDErr = -260;            {duplicate client ID}
  113. midiInvalidCmdErr = -261;       {command not supported for port type}
  114.  
  115. {     Driver calls: }
  116. midiOpenDriver = 1;
  117. midiCloseDriver = 2;
  118.  
  119. TYPE
  120. MIDIPacketPtr = ^MIDIPacket;
  121. MIDIPacket = PACKED RECORD
  122.     flags: Byte;
  123.     len: Byte;
  124.     tStamp: LONGINT;
  125.     data: PACKED ARRAY [0..248] OF Byte;
  126.     END;
  127.  
  128. MIDIClkInfo = RECORD
  129.     sync: INTEGER;              {synchronization external/internal}
  130.     curTime: LONGINT;           {current value of port's clock}
  131.     format: INTEGER;            {time code format}
  132.     END;
  133.  
  134. MIDIIDRec = RECORD
  135.     clientID: OSType;
  136.     portID: OSType;
  137.     END;
  138.  
  139. MIDIPortInfoPtr = ^MIDIPortInfo;
  140. MIDIPortInfoHdl = ^MIDIPortInfoPtr;
  141. MIDIPortInfo = RECORD
  142.     portType: INTEGER;          {type of port}
  143.     timeBase: MIDIIDRec;        {MIDIIDRec for time base}
  144.     numConnects: INTEGER;       {number of connections}
  145.     cList: ARRAY [1..100] OF MIDIIDRec;
  146.     END;
  147.  
  148. MIDIPortParamsPtr = ^MIDIPortParams;
  149. MIDIPortParams = RECORD
  150.     portID: OSType;             {ID of port, unique within client}
  151.     portType: INTEGER;          {Type of port - input, output, time, etc.}
  152.     timeBase: INTEGER;          {refnum of time base, 0 if none}
  153.     offsetTime: LONGINT;        {offset for current time stamps}
  154.     readHook: Ptr;              {routine to call when input data is valid}
  155.     refCon: LONGINT;            {refcon for port (for client use)}
  156.     initClock: MIDIClkInfo;     {initial settings for a time base}
  157.     name: Str255;               {name of the port, This is a real live string, not a ptr.}
  158.     END;
  159.  
  160. MIDIIDListPtr = ^MIDIIDList;
  161. MIDIIDListHdl = ^MIDIIDListPtr;
  162. MIDIIDList = RECORD
  163.     numIDs: INTEGER;
  164.     list: ARRAY [1..100] OF OSType;
  165.     END;
  166.  
  167.  
  168. {
  169.      Prototype Declarations for readHook and timeProc
  170.     
  171.      FUNCTION myReadHook(myPacket: MIDIPacketPtr; myRefCon: LONGINT) : INTEGER;
  172.      PROCEDURE myTimeProc(curTime: LONGINT; myRefCon: LONGINT);
  173. }
  174.  
  175. FUNCTION SndDispVersion(toolnum: INTEGER): LONGINT;
  176. FUNCTION MIDISignIn(clientID: OSType;refCon: LONGINT;icon: Handle;name: Str255): OSErr;
  177.     INLINE $203C,$0004,midiToolNum,$A800;
  178. PROCEDURE MIDISignOut(clientID: OSType);
  179.     INLINE $203C,$0008,midiToolNum,$A800;
  180. FUNCTION MIDIGetClients: MIDIIDListHdl;
  181.     INLINE $203C,$000C,midiToolNum,$A800;
  182. PROCEDURE MIDIGetClientName(clientID: OSType;VAR name: Str255);
  183.     INLINE $203C,$0010,midiToolNum,$A800;
  184. PROCEDURE MIDISetClientName(clientID: OSType;name: Str255);
  185.     INLINE $203C,$0014,midiToolNum,$A800;
  186. FUNCTION MIDIGetPorts(clientID: OSType): MIDIIDListHdl;
  187.     INLINE $203C,$0018,midiToolNum,$A800;
  188. FUNCTION MIDIAddPort(clientID: OSType;BufSize: INTEGER;VAR refnum: INTEGER;
  189.     init: MIDIPortParamsPtr): OSErr;
  190.     INLINE $203C,$001C,midiToolNum,$A800;
  191. FUNCTION MIDIGetPortInfo(clientID: OSType;portID: OSType): MIDIPortInfoHdl;
  192.     INLINE $203C,$0020,midiToolNum,$A800;
  193. FUNCTION MIDIConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  194.     dstPortID: OSType): OSErr;
  195.     INLINE $203C,$0024,midiToolNum,$A800;
  196. FUNCTION MIDIUnConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  197.     dstPortID: OSType): OSErr;
  198.     INLINE $203C,$0028,midiToolNum,$A800;
  199. FUNCTION MIDIConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  200.     dstPortID: OSType): OSErr;
  201.     INLINE $203C,$002C,midiToolNum,$A800;
  202. FUNCTION MIDIUnConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  203.     dstPortID: OSType): OSErr;
  204.     INLINE $203C,$0030,midiToolNum,$A800;
  205. PROCEDURE MIDIFlush(refnum: INTEGER);
  206.     INLINE $203C,$0034,midiToolNum,$A800;
  207. FUNCTION MIDIGetReadHook(refnum: INTEGER): ProcPtr;
  208.     INLINE $203C,$0038,midiToolNum,$A800;
  209. PROCEDURE MIDISetReadHook(refnum: INTEGER;hook: ProcPtr);
  210.     INLINE $203C,$003C,midiToolNum,$A800;
  211. PROCEDURE MIDIGetPortName(clientID: OSType;portID: OSType;VAR name: Str255);
  212.     INLINE $203C,$0040,midiToolNum,$A800;
  213. PROCEDURE MIDISetPortName(clientID: OSType;portID: OSType;name: Str255);
  214.     INLINE $203C,$0044,midiToolNum,$A800;
  215. PROCEDURE MIDIWakeUp(refnum: INTEGER;time: LONGINT;period: LONGINT;timeProc: ProcPtr);
  216.     INLINE $203C,$0048,midiToolNum,$A800;
  217. PROCEDURE MIDIRemovePort(refnum: INTEGER);
  218.     INLINE $203C,$004C,midiToolNum,$A800;
  219. FUNCTION MIDIGetSync(refnum: INTEGER): INTEGER;
  220.     INLINE $203C,$0050,midiToolNum,$A800;
  221. PROCEDURE MIDISetSync(refnum: INTEGER;sync: INTEGER);
  222.     INLINE $203C,$0054,midiToolNum,$A800;
  223. FUNCTION MIDIGetCurTime(refnum: INTEGER): LONGINT;
  224.     INLINE $203C,$0058,midiToolNum,$A800;
  225. PROCEDURE MIDISetCurTime(refnum: INTEGER;time: LONGINT);
  226.     INLINE $203C,$005C,midiToolNum,$A800;
  227. PROCEDURE MIDIStartTime(refnum: INTEGER);
  228.     INLINE $203C,$0060,midiToolNum,$A800;
  229. PROCEDURE MIDIStopTime(refnum: INTEGER);
  230.     INLINE $203C,$0064,midiToolNum,$A800;
  231. PROCEDURE MIDIPoll(refnum: INTEGER;offsetTime: LONGINT);
  232.     INLINE $203C,$0068,midiToolNum,$A800;
  233. FUNCTION MIDIWritePacket(refnum: INTEGER;packet: MIDIPacketPtr): OSErr;
  234.     INLINE $203C,$006C,midiToolNum,$A800;
  235. FUNCTION MIDIWorldChanged(clientID: OSType): BOOLEAN;
  236.     INLINE $203C,$0070,midiToolNum,$A800;
  237. FUNCTION MIDIGetOffsetTime(refnum: INTEGER): LONGINT;
  238.     INLINE $203C,$0074,midiToolNum,$A800;
  239. PROCEDURE MIDISetOffsetTime(refnum: INTEGER;offsetTime: LONGINT);
  240.     INLINE $203C,$0078,midiToolNum,$A800;
  241. FUNCTION MIDIConvertTime(srcFormat: INTEGER;dstFormat: INTEGER;time: LONGINT): LONGINT;
  242.     INLINE $203C,$007C,midiToolNum,$A800;
  243. FUNCTION MIDIGetRefCon(refnum: INTEGER): LONGINT;
  244.     INLINE $203C,$0080,midiToolNum,$A800;
  245. PROCEDURE MIDISetRefCon(refnum: INTEGER;refCon: LONGINT);
  246.     INLINE $203C,$0084,midiToolNum,$A800;
  247. FUNCTION MIDIGetClRefCon(clientID: OSType): LONGINT;
  248.     INLINE $203C,$0088,midiToolNum,$A800;
  249. PROCEDURE MIDISetClRefCon(clientID: OSType;refCon: LONGINT);
  250.     INLINE $203C,$008C,midiToolNum,$A800;
  251. FUNCTION MIDIGetTCFormat(refnum: INTEGER): INTEGER;
  252.     INLINE $203C,$0090,midiToolNum,$A800;
  253. PROCEDURE MIDISetTCFormat(refnum: INTEGER;format: INTEGER);
  254.     INLINE $203C,$0094,midiToolNum,$A800;
  255. PROCEDURE MIDISetRunRate(refnum: INTEGER;rate: INTEGER;time: LONGINT);
  256.     INLINE $203C,$0098,midiToolNum,$A800;
  257. FUNCTION MIDIGetClientIcon(clientID: OSType): Handle;
  258.     INLINE $203C,$009C,midiToolNum,$A800;
  259.  
  260.  
  261.     { UsingMIDI }
  262.  
  263.  
  264.     IMPLEMENTATION
  265. END.
  266.  
  267.  
  268.